const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const OptimizeCSSPlugin = require("optimize-css-assets-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = merge(common, {
    plugins: [
        new CleanWebpackPlugin(),
        new UglifyJsPlugin({
            parallel: true,
        }),
        new OptimizeCSSPlugin({
            cssProcessorOptions: { safe: true },
        }),
        new CopyWebpackPlugin({
            patterns: [
                {
                    from: "public",
                },
            ],
        }),
    ],
    optimization: {
        splitChunks: {
            chunks: "all",
        },
        concatenateModules: true,
        usedExports: true,
        minimize: true,
    },
});
